export class Menu {
  id?: number;
  name = '';
  icon?: string;
  menuType = 'M';
  pid = 0
  sort?: number = 0;
  perms?: string;
  component?: string;
  isShow = true
  constructor(data?: Menu) {
    data && this.setProps(data);
  }

  setProps(data: Menu) {
    (Object.keys(this) as Array<keyof IMenu>).forEach((key) => {
      // @ts-ignore
      this[key] = data[key]
    })
  }
}

export type IMenu = Omit<Menu, 'setProps'> & {
  children?: IMenu[]
}